import request from '@/utils/request'

enum Api{
    //根据spuId获取sku数据
    getSkuListApi = '/admin/product/findBySpuId',
    //添加skuinfo
    saveSkuInfoApi= '/admin/product/saveSkuInfo',
    //获取skuingo
    getSkuinfoApi = '/admin/product/getSkuInfo/{skuId}',
    //获取sku页的数据
    getSkuApi = '/admin/product/list',
    //下架请求接口
    CancelApi = '/admin/product/cancelSale',
    //商家请求接口
    OnApi = '/admin/product/onSale',
    //请求一条sku接口
    getOneSkuInfo = '/admin/product/getSkuById',
    //删除一条sku接口
    deleteOneSku = '/admin/product/deleteSku'
}

//添加skuinfo数据
export const reqSaveSkuInfo = (skuInfo)=>{
    return request.post<any,any>(Api.saveSkuInfoApi,skuInfo)
}
//获取sku数据
export const reqGetSkuListData = (spuId:number)=>{
    return request.get<any,any>(Api.getSkuListApi+`/${spuId}`)
} 

//获取skuinfo数据
export const reqGetSkuInfoData = (spuId:number)=>{
    return request.get<any,any>(Api.getSkuinfoApi,spuId)
}

//获取sku页数据

export const reqGetSku = (page:number,limit:number)=>{
    return request.get<any,any>(Api.getSkuApi+`/${page}/${limit}`)
}
//下架请求函数
export const reqCancelSale = (skuId:number)=>{
    return request.get(Api.CancelApi+`/${skuId}`)
}

//下架请求函数
export const reqOnSale = (skuId:number)=>{
    return request.get(Api.OnApi+`/${skuId}`)
}

export const reqGetOneSku = (skuId:number)=>{
    return request.get(Api.getOneSkuInfo+`/${skuId}`)
}


export const reqDelOneSku = (skuId:number)=>{
    return request.delete(Api.deleteOneSku+`/${skuId}`)
}